#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define H_W_Y

mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());

const int N=5e5+5;
int n,m,q;
ll d[N],val[N],h[64];
bool vis[N];
struct Nod{
  int v,w;
};
vector<Nod> G[N];

void dfs(int u,int fa){
  vis[u]=true;
  for(auto i:G[u]){
	int v=i.v,w=i.w;
	if(!vis[v]) dfs(v,u),d[u]^=d[v],val[w]=d[v];
	else if(v!=fa&&!val[w]) val[w]=rd(),d[u]^=val[w],d[v]^=val[w]; 
  }
}

bool ins(ll x){
  for(int i=60;i>=0;i--){
    if((x>>i)&1){
	  if(!h[i]){
	    h[i]=x;
		return true;
	  }
	  x^=h[i];
	}
  }
  return false;
}

int main(){
  #ifdef H_W_Y
  freopen("graph.in","r",stdin);
  freopen("graph.out","w",stdout);
  #endif

  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>m;
  for(int i=1,u,v;i<=m;i++) cin>>u>>v,G[u].pb({v,i}),G[v].pb({u,i});
  dfs(1,1);
  cin>>q;
  while(q--){
	int k,x,fl=1;cin>>k;
	memset(h,0,sizeof(h));
	while(k--) cin>>x,fl&=ins(val[x]);
    if(fl) cout<<"YES\n";
	else cout<<"NO\n";
  }
  return 0;
}